package com.studio49.exmple.core.config;

import java.util.Arrays;
import java.util.List;

import com.studio49.exmple.core.filter.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfigurer implements WebMvcConfigurer {
	
	@Autowired
    LoginInterceptor loginInterceptor;
	
	private static List<String> EXCLUDE_PATH = Arrays.asList("/favicon.ico", "/login/**", "/js/**", "/images/**", "/css/**", "/plugin/**", 
			"/common/**", "/webjars/**", "/static/**", "/appInterface/**");
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		
//		//springboot 已经做好静态资源映射
		registry.addInterceptor(loginInterceptor)
		.addPathPatterns("/**")
		.addPathPatterns("/")
		.excludePathPatterns(EXCLUDE_PATH);
//		super.addInterceptors(registry);
		
	}
	
}
